package com.lantosec.hmrp.modules.monitor.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lantosec.hmrp.core.kit.PageVO;
import com.lantosec.hmrp.core.kit.Result;
import com.lantosec.hmrp.core.mvc.BaseController;
import com.lantosec.hmrp.modules.monitor.entity.ProcessEntity;
import com.lantosec.hmrp.modules.monitor.service.IMonitorProcessService;
import com.lantosec.hmrp.modules.sysdata.entity.SysDataProcess;
import com.lantosec.hmrp.modules.sysdata.service.ISysDataProcessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *
 * 大屏流程控制器
 *
 * @author AutoCode
 * @since 2020-05-27
 */
@Api(value = "大屏流程控制器", tags = "大屏流程控制器")
@RestController
@RequestMapping("/monitor/process")
@Log4j2
public class MonitorProcessController extends BaseController {

    @Autowired
    private IMonitorProcessService service;

    @Autowired
    private ISysDataProcessService dataProcessService;

    @GetMapping("getProcessTypeTotal")
    @ApiOperation(value = "流程分类汇总数字")
    public Result<List<ProcessEntity>> getProcessTypeTotal(
            @ApiParam(value = "月份") @RequestParam(name = "month",required = false) String month,
            @ApiParam(value = "年份") @RequestParam(name = "year",required = false) String year
    ) {
        List<ProcessEntity> total = service.getProcessTypeTotal(month,year);
        return Result.ok(total);
    }

    @GetMapping("getProcessStatusTotal")
    @ApiOperation(value = "已完成未完成数据汇总数字")
    public Result<List<ProcessEntity>> getProcessStatusTotal(
            @ApiParam(value = "月份") @RequestParam(name = "month",required = false) String month,
            @ApiParam(value = "年份") @RequestParam(name = "year",required = false) String year
    ) {
        List<ProcessEntity> total = service.getProcessStatusTotal(month,year);
        return Result.ok(total);
    }

    @GetMapping("getProcessStatusDetails")
    @ApiOperation(value = "根据已完成未完成详情")
    public Result<Page<SysDataProcess>> getProcessStatusDetails(
            @ApiParam(value = "分页对象", required = true) PageVO<SysDataProcess> page,
            @ApiParam(value = "月份") @RequestParam(name = "month",required = false) String month,
            @ApiParam(value = "年份") @RequestParam(name = "year",required = false) String year,
            @ApiParam(value = "流程分类id") @RequestParam(name = "processTypeId",required = false) String processTypeId,
            @ApiParam(value = "流程状态") @RequestParam(name = "processStatus",required = false) String processStatus
    ) {
        Page<SysDataProcess> list = service.queryProcessInstanceList(page,month,year,processTypeId,processStatus);
        return Result.ok(list);
    }

    @GetMapping("getProcessTotal")
    @ApiOperation(value = "查看流程汇总数字")
    public Result<ProcessEntity> getProcessTotal(
            @ApiParam(value = "月份") @RequestParam(name = "month",required = false) String month,
            @ApiParam(value = "年份") @RequestParam(name = "year",required = false) String year
    ) {
        ProcessEntity total = service.getProcessTotal(month,year);
        return Result.ok(total);
    }
}
